{% extends 'template.html' %}

{% block username %}
    {{ head.username }}
{% endblock %}

{% block content %}
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">{{ head.value }}</h1>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <div class="btn-group">
                            <a>
                                <button id='bt-search' type="button" class="btn btn-success">高级搜索</button>
                            </a>
                            <a>
                                <button id='bt-reset' type="button" class="btn btn-danger">重置高级搜索</button>
                            </a>
                            {% if request.user.is_superuser %}
                                <a>
                                    <button id='bt-reset' type="button" class="btn btn-outline btn-success"
                                            onclick="batch_action('start')">批量开服
                                    </button>
                                </a>
                                <a>
                                    <button id='bt-reset' type="button" class="btn btn-outline btn-info"
                                            onclick="batch_action('stop')">批量关服
                                    </button>
                                </a>
                                <a>
                                    <button id='bt-reset' type="button" class="btn btn-outline btn-warning"
                                            onclick="batch_action('restart')">批量重启
                                    </button>
                                </a>
                                <a>
                                    <button id='bt-reset' type="button" class="btn btn-outline btn-danger"
                                            onclick="batch_action('clean')">批量清档
                                    </button>
                                </a>
                            {% endif %}
                        </div>
                        <div class="pull-right">
                            <div class="btn-group">
                            </div>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div id="div-search" class="hide">
                            <table id="high-search" style="width: 67%; margin: 0 auto 2em auto;" border="0"
                                   cellpadding="3" cellspacing="0">
                                <thead>
                                <tr>
                                    <th>目标</th>
                                    <th>内容</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr data-column="2">
                                    <td>项目类型</td>
                                    <td align="center">
                                        <select id="filter_project_type" class="filter_select2" style="width: 100%">
                                            <option value="100" selected="selected">全部</option>
                                            <option value="0">手游</option>
                                            <option value="1">页游</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr data-column="5">
                                    <td>项目名称</td>
                                    <td align="center">
                                        <select id="filter_project" class="filter_select2" style="width: 100%">
                                            <option value="0" selected="selected">全部</option>
                                            {% for project in all_project %}
                                                <option value={{ project.id }}>{{ project.text }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr data-column="5">
                                    <td>状态</td>
                                    <td align="center">
                                        <select id="filter_srv_status" class="filter_select2" style="width: 100%">
                                            <option value="100" selected="selected">全部</option>
                                            {% for id, value in all_srv_status.items %}
                                                <option value={{ id }}>{{ value }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr data-column="2">
                                    <td>游戏类型</td>
                                    <td align="center">
                                        <select id="filter_game_type" class="filter_select2" style="width: 100%">
                                            <option value="0" selected="selected">全部</option>
                                            {% for game_type in all_game_type %}
                                                <option value={{ game_type.id }}>{{ game_type.text }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr data-column="4">
                                    <td>平台名</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_pf_name" type="text"></td>
                                </tr>
                                <tr data-column="4">
                                    <td>区服id</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_srv_id" type="text"></td>
                                </tr>
                                <tr data-column="4">
                                    <td>区服名称</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_srv_name" type="text"></td>
                                </tr>
                                <tr data-column="5">
                                    <td>机房</td>
                                    <td align="center">
                                        <select id="filter_room" class="filter_select2" style="width: 100%">
                                            <option value="0" selected="selected">全部</option>
                                            {% for room in all_room %}
                                                <option value={{ room.id }}>{{ room.text }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr data-column="4">
                                    <td>内网IP</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_internal_ip" type="text"></td>
                                </tr>
                                <tr data-column="4">
                                    <td>电信IP</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_telecom_ip" type="text"></td>
                                </tr>
                                <tr data-column="4">
                                    <td>联通IP</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_unicom_ip" type="text"></td>
                                </tr>
                                <tr data-column="4">
                                    <td>主服id</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_merge_id" type="text"></td>
                                </tr>
                                <tr data-column="4">
                                    <td>合服时间</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_merge_time" type="text"></td>
                                </tr>
                                <tr data-column="4">
                                    <td>前端版本号</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_client_version" type="text"></td>
                                </tr>
                                <tr data-column="4">
                                    <td>后端版本号</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_server_version" type="text"></td>
                                </tr>
                                <tr data-column="4">
                                    <td>cdn_root_url</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_cdn_root_url" type="text"></td>
                                </tr>
                                <tr data-column="4">
                                    <td>cdn目录</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_cdn_dir" type="text"></td>
                                </tr>
                                <tr data-column="4">
                                    <td>开服时间</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_open_time" type="text"></td>
                                </tr>
                                <tr data-column="4">
                                    <td>地区</td>
                                    <td align="center">
                                        <select id="filter_area_name" class="filter_select2" style="width: 100%">
                                            <option value="0" selected="selected">全部</option>
                                            {% for area in all_area %}
                                                <option value={{ area.chinese_name }}>{{ area.chinese_name }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr data-column="6">
                                    <td>只看主服</td>
                                    <td align="center"><input type="checkbox" id='master_server'></td>
                                </tr>
                                <tr data-column="4">
                                    <td>sid</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_sid" type="text"></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="col-sm-2">
                            <label>选择项目</label>
                            <select id="filter_project2" style="width: 100%">
                                <option value="0" selected>全部</option>
                                {% for p in all_project %}
                                    <option value="{{ p.id }}">{{ p.text }}</option>
                                {% endfor %}
                            </select>
                        </div>
                        <div class="col-sm-2">
                            <label>选择机房</label>
                            <select id="filter_room2" style="width: 100%">
                                <option value="0" selected>全部</option>
                                {% for r in all_room %}
                                    <option value="{{ r.id }}">{{ r.text }}</option>
                                {% endfor %}
                            </select>
                        </div>
                        <div class="col-sm-3">
                            <label>状态(可多选)</label>
                            <select id="filter_srv_status2" style="width: 100%" multiple>
                                {% for k, v in all_srv_status.items %}
                                    <option value="{{ k }}">{{ v }}</option>
                                {% endfor %}
                            </select>
                        </div>
                        <br/><br/><br/><br/>
                        <form>
                            <div class="form-group">
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="2" class="toggle-visiable">项目类型
                                </label>
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="8" class="toggle-visiable">区服名
                                </label>
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="12" class="toggle-visiable">合服时间
                                </label>
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="17" class="toggle-visiable">开服时间
                                </label>
                                <label class="checkbox-inline">
                                    <input type="checkbox" value="19" class="toggle-visiable">sid
                                </label>
                            </div>
                        </form>
                        <table id="mytable" class="display" width="100%" cellspacing="0">
                            <thead>
                            <tr>
                                <th class="center sorting_disabled">
                                    <label class="pos-rel">
                                        <input id='chb-all' type="checkbox"/>
                                    </label>
                                </th>
                                <th>id</th>
                                <th>项目类型</th>
                                <th>项目名</th>
                                <th>状态</th>
                                <th>游戏类型</th>
                                <th>平台名</th>
                                <th>区服id</th>
                                <th>区服名</th>
                                <th>机房</th>
                                <th>IP</th>
                                <th>主服id</th>
                                <th>合服时间</th>
                                <th>前端版本号</th>
                                <th>后端版本号</th>
                                <th>cdn根url</th>
                                <th>cdn目录</th>
                                <th>开服时间</th>
                                <th>地区</th>
                                <th>sid</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>

            <!-- Modal -->
            <div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel"></h4>
                        </div>
                        <div class="modal-body">
                            <div class="alert alert-danger alert-dismissable" id='modal-notify'>
                                <button type="button" class="close" id="bt-modal-notify">&times;</button>
                                <label id='lb-msg'></label>
                            </div>
                            <form class="form-horizontal" role="form">
                                <div class="form-group" id='show_id'>
                                    <label class="col-sm-3 control-label">id</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control " placeholder="" id="id">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">游戏项目中文名</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" placeholder="" id="project_name">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">游戏项目英文名</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" placeholder="" id="project_name_en">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">svn仓库名</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" placeholder="" id="svn_repo">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">项目负责人(可选)</label>
                                    <div class="col-sm-8">
                                        <select class="form-control" id="leader">
                                            <option value="0" selected="selected">选择负责人</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">所属部门</label>
                                    <div class="col-sm-8">
                                        <select class="form-control" id="group" style="width: 50%">
                                            <option value="0" selected="selected">选择部门</option>
                                        </select>
                                        <button id='del_gorup' type="button" class="btn btn-default btn-sm">x</button>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">状态</label>
                                    <div class="col-sm-8">
                                        <select class="form-control" id="status">
                                            <option value=0>停用</option>
                                            <option value=1 selected="selected">可用</option>
                                        </select>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button id='bt-save' type="button" class="btn btn-primary">保存</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div><!-- /.modal -->

            <div class="modal fade" id="Modal-file" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel">导入/导出</h4>
                        </div>
                        <form id="submit-file-form" enctype="multipart/form-data" action="/assets/upload_devices"
                              method="post">
                            <!-- {% csrf_token %} -->
                            <div class="modal-body">
                                <div class="alert alert-dismissable" id='upload-notify'>
                                    <button type="button" class="close" id="bt-upload-notify">&times;</button>
                                    <label id='lb-msg-upload'></label>
                                </div>
                                <div class="form-group">
                                    {{ form }}
                                    <p class="help-block">Example block-level help text here.</p>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="submit" class="btn btn-primary" name='action'>保存</button>
                            </div>
                        </form>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div>

            <!-- 单个区服管理（开服/关服/重启/清档）-->
            <div class="modal fade" id="Modal-manager" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-body">
                            <h5>确认要 <span class="text-danger" id="modalBodyMessgae"></span> 吗？</h5>
                            <input style="display: none;" id="modalSrvId_manager">
                            <input style="display: none;" id="modalSrvType_action">
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary" onclick="game_server_action()">
                                确认
                            </button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div>

            <!-- 批量区服管理（开服/关服/重启/清档）-->
            <div class="modal fade" id="Modal-manager-batch" role="dialog" aria-labelledby="myModalLabel"
                 aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-body">
                            <span class="text-danger" id="modalBodyMessgaeBatch"></span>
                            <input style="display: none;" id="batch_action_type">
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary" onclick="batch_game_server_action()">
                                确认
                            </button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div>

            <!-- 区服管理操作提示-->
            <div class="modal fade" id="Modal-notice" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-body">
                            <strong><span id="action_notice_text"></span></strong>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div>

            <!-- 区服操作历史记录展示-->
            <div class="modal fade" id="Modal-history" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel">区服操作记录</h4>
                        </div>
                        <div class="modal-body" id="action_history_content">

                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div>

            <!-- 单个区服迁服操作-->
            <div class="modal fade" id="Modal-migrate" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-body">
                            <h5>确认要将 <span class="text-danger" id="migrate_srv_id"></span> 迁服吗？</h5>
                            <stong>请确认该区服所在项目已对接迁服接口，配置文件已正确填写迁服主机IP！</stong>
                            <input style="display: none;" id="migrate_game_server_id">
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary" onclick="game_server_migrate()">
                                确认
                            </button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div>

            <!-- 管理员标志-->
            <div id="is_superuser" data-is-superuser="{{ is_superuser }}"></div>

        </div>
    </div>
{% endblock %}
{% block bodyjs %}
    <script src="/static/js/jquery.dataTables.js"></script>
    {{ django_context_varable }}
    {% verbatim %}
    <script id="tpl" type="text/x-handlebars-template">
        {{#each func}}
        <button type="button" class="btn btn-{{this.type}} btn-sm" onclick="{{this.fn}}">{{this.name}}</button>
        {{/each}}
    </script>
    {% endverbatim %}
    <script src="/static/js/handlebars-v3.0.1.js"></script>
    <script src="/static/js/reconnecting-websocket.js"></script>
    <script src="/static/js/game_server_list.js?v=20191128001"></script>
    <script src="/static/js/dataTables.colVis.js"></script>
    <script src="/static/js/zebra_datepicker.js"></script>
{% endblock %}
{% block css %}
    <link href="/static/css/jquery.dataTables.css" rel="stylesheet" type="text/css">
    <link href="/static/css/mycss.css" rel="stylesheet" type="text/css">
    <link href="/static/css/dataTables.colVis.css" rel="stylesheet" type="text/css">
    <link href="/static/css/datetimepicker.css">
    <link href="/static/css/select2-bootstrap.css" rel="stylesheet" type="text/css">
{% endblock %}
